#ifndef _CAN_MSG_H
#define _CAN_MSG_H

#include "stm32f4xx_hal.h"
#include "common.h"
#define CAN_FIFO_MAX_LEN 50


typedef struct t_CAN_RXMSG
{
    uint16_t   id;
    unsigned char *pCanData;//接受数据
    unsigned int  *pLostCnt;//接受数据个数
    unsigned int  *pOkCnt; //收到的数据个数
}CAN_RXMSG;



typedef struct tag_CanTxMsg
{
    unsigned long StdId;
    unsigned long ExtId;
    unsigned char DLC;
    unsigned char Data[8];
} CanTxMsg;

typedef struct tag_CanRxMsg
{
    unsigned long StdId;
    unsigned long ExtId;
    unsigned char DLC;
    unsigned char Data[8];
} CanRxMsg;


//Can TxMessage--------------------------------------------------------------
typedef struct t_CAN_TXMSG
{
    unsigned long  id;               //报文ID
    unsigned char  dlc;              //长度
    unsigned char* pCanData;        //数据指针
    unsigned short timesOk;         //2字节  times最大时间
    unsigned short timesCnt;        //定时器计时时间
    unsigned char  *ptrg;           //触发标志指针
    void (*TxCallBackFun)(void);
} CAN_TXMSG;

//TX数据发送
typedef struct
{
    uint8_t   busOffFlag:1;
    uint8_t   txOk;//数据发送完成
	uint8_t   sendNext;//发送下一帧数据
    uint8_t   txEnable;//数据发送确认
    uint16_t  head;
    uint16_t  back;
	uint16_t  txCnt;
    CanTxMsg  txBuf[CAN_FIFO_MAX_LEN];
}CAN_TxStruDef;



//队列数据存储
typedef struct _CAN_MsgCB
{
    int head;
    int back;
    CanRxMsg canRxData[CAN_FIFO_MAX_LEN];
}CAN_MsgCB;
//队列数据存储


typedef union 
{
    uint8_t data[8];
    struct 
    {
        uint8_t res1        :8;
        uint8_t res2        :8;
        uint8_t res3        :8;
        uint8_t res4        :8;
        uint8_t res5        :8;
        uint8_t res6        :8;
        uint8_t res7        :8;
        uint8_t res8        :8;
    }ID_0x595;
}Updata_Id_t;//升级ID命令

#endif
